import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import AboutUs from '../views/AboutUs.vue'
import StadiumShow from '../views/StadiumShow.vue'
import CourseDescription from '../views/CourseDescription.vue'
import EliteTeam from '../views/EliteTeam.vue'
import BookClass from '../views/BookClass.vue'

Vue.use(VueRouter)

const routes = [
  // 首页
  { path: "/", name: "Home", component: Home, meta: { title: "尼莫亲子游泳俱乐部"} },
  // 关于我们
  { path: "/aboutUs", name: "AboutUs", component: AboutUs, meta: { title: "关于我们-尼莫亲子游泳俱乐部"} },
  // 场馆介绍
  { path: "/stadiumShow", name: "StadiumShow", component: StadiumShow, meta: { title: "场馆介绍-尼莫亲子游泳俱乐部"} },
  // 课程介绍
  { path: "/courseDescription", name: "CourseDescription", component: CourseDescription, meta: { title: "课程介绍-尼莫亲子游泳俱乐部"} },
  // 精英团队
  { path: "/eliteTeam", name: "EliteTeam", component: EliteTeam, meta: { title: "精英团队-尼莫亲子游泳俱乐部"} },
  // 预约上课
  { path: "/bookClass", name: "BookClass", component: BookClass, meta: { title: "预约上课-尼莫亲子游泳俱乐部"} },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 全局前置守卫   主要 用于登录验证
/**
 * @param {to} 将要去的路由
 * @param {from} 出发的路由
 * @param {next} 执行下一步
 */
 router.beforeEach((to, _, next) => {
  // document.title = to.meta.title || '卖座电影';
  //判断当前路由是否需要进行权限控制
  document.title = to.meta.title;//修改页签
  next();//允许进入
});

export default router
